package com.freecloud.javabasics.thread.CountDownLatch;

import java.util.concurrent.CountDownLatch;

/**
 * @Author: maomao
 * @Date: 2020-02-23 17:20
 */
public class CountDownLatchDemo2 extends Thread {

    static CountDownLatch countDownLatch = new CountDownLatch(1);


    @Override
    public void run() {
        try {
            countDownLatch.await();//阻塞
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("ThreadName:" + Thread.currentThread().getName());
    }


    public static void main(String[] args) {
        for (int i = 0; i < 1000; i++) {
            new CountDownLatchDemo2().start();
        }

        //唤醒阻塞的所有线程
        //countDownLatch.countDown();

        System.out.println("countDownLatch end!");
    }
}
